$(function(){
    var i=0;//大总管
    	var timer;//控制大图轮播的定时器
    	var length = $('#box .point i').length;
    	var timerOut;//定时炸弹
    	timer = setInterval(run,1000);
    	//run方法用来控制ul的运动
    	function run(){
    		i++;
    		if(i>length){
    			i=1;
    			$('#box ul').css('left',0);
    		}
    		$('#box ul').stop().animate({left:-510*i});
    		focus(i);
    	}
    	
    	function focus(index){
    		if(index==length){
    			index = 0;
    		}
    		$('#box .point i').eq(index).addClass('active').siblings().removeClass('active');
    	}
    	$('#box').hover(function(){
    		clearInterval(timer);
    	},function(){
    		timer = setInterval(run,1000);
    	})
    	
    	$('#box .point i').mouseover(function(){
    		var This = this;
    		clearTimeout(timerOut);	
    		timerOut = window.setTimeout(function(){
    			var index = $(this).index();
    			i=index;
    			$('#box ul').stop().animate({left:-510*index});
    			focus(index);
    		},200);
    	})
    	$('#box .right').click(function(){
    		run();
    	})
    	$('#box .left').click(function(){
    		i--;
    		if(i<0){
    			i=length-1;
    			$('#box ul').css({left:length*-510});
    		}
    		focus(i);
    		$('#box ul').stop().animate({left:-510*i});
    	})
})